<html>
<head><meta charset="utf-8"><title>redundant-type-params new lint · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/redundant-type-params.20new.20lint.html">redundant-type-params new lint</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217707509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/redundant-type-params%20new%20lint/near/217707509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/redundant-type-params.20new.20lint.html#217707509">(Nov 24 2020 at 02:16)</a>:</h4>
<p>Good evening!</p>
<p>While working on some nalgebra stuff, i was refactoring my code to use a type parameter for <code>Vector3&lt;f64&gt;</code>. I realized that a lot of the code i missed still has <code>Vector3&lt;f64&gt;</code> which is implied by <code>Vector3&lt;T = f64&gt;</code> in my type. Therefore i was thinking it could be useful to perhaps have a lint which warns against this kind of thing, where the usage of a type parameter on a type declaration is redundant because the passed type parameter is equal the default. e.g. </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u8</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">a</span>: <span class="nc">Bar</span><span class="o">&lt;</span><span class="kt">u8</span><span class="o">&gt;</span><span class="w"></span>
<span class="c1">//   ^^^^^^^ warn: `Bar&lt;u8&gt;` is redundant as `Bar` defaults to `Bar&lt;u8&gt;`</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Any thoughts on this addition?</p>



<a name="217764011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/redundant-type-params%20new%20lint/near/217764011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Broto <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/redundant-type-params.20new.20lint.html#217764011">(Nov 24 2020 at 14:54)</a>:</h4>
<p>I think that would be fine to add but IMO it should be pedantic as it doesn't do any harm. Also it could be problematic in some contexts having to special case the default parameter.</p>



<a name="217772963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/redundant-type-params%20new%20lint/near/217772963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/redundant-type-params.20new.20lint.html#217772963">(Nov 24 2020 at 15:56)</a>:</h4>
<p>I can see a lint like this. Can you open a "New Lint"-Issue in the Clippy repo for this, please? (Group pedantic also SGTM)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>